using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace GameFrameworkLibraly.Helpers
{
    public static class Utils
    {
        public static Array GetEnumValues(this Type enumerationType)
        {
            if (!enumerationType.IsEnum)
                throw new Exception("GetEnumValues(enumerationType). Error: Argument is not an enum type!");

            object valAux = Activator.CreateInstance(enumerationType);
            FieldInfo[] fieldInfoArray = enumerationType.GetFields(BindingFlags.Static | BindingFlags.Public);

            Array res = Array.CreateInstance(enumerationType, fieldInfoArray.Length);
            for (int i = 0; i < res.Length; i++)
                res.SetValue(fieldInfoArray[i].GetValue(valAux), i);
            return res;
        }
    }
}
